#include <interface\toggleButton.h>
#include <interface\window.h>
#include <interface\gl.h>

toggleButton::toggleButton():   button()
{
        ELname = "<toggleButton>";
}
toggleButton::toggleButton(window* win):    button(win)
{
        ELname = "<toggleButton>";
}

void toggleButton::mouseClickEvent(int mse){
    button::mouseClickEvent(mse);
    status = !status;
    if( parentWin ) parentWin->eventListener(new actionToggleEvent(this));
}

void toggleButton::display(){
    if( !styleS ) return;
    abstractButton::display();
    int pOffX = 0;
    int pOffY = 0;
    getOffset(&pOffX,&pOffY);
    glColor(bkgColFromSS(elm_toggleButton));
    glDrawRect(enc,pOffX,pOffY);
    glColor(txtColFromSS(elm_toggleButton));
    label.display(enc.left+pOffX-1+margin.left,enc.bottom+pOffY+1+margin.bottom);
}

actionToggleEvent::actionToggleEvent(winElmt* e):   event( e )
{
    type = event_type_action_toggle;
}
